//
//  ProductDetialView.m
//  ForestPack
//
//  Created by 骆锴 on 2018/8/7.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "ProductDetialView.h"
#import "ProductDetialCell.h"

@interface ProductDetialView () <UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,strong) BaseTableView *tableView;

@end

@implementation ProductDetialView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        
        self.shadowBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
        self.shadowBtn.backgroundColor = [UIColor colorWithWhite:0 alpha:0.3];
        self.shadowBtn.alpha = 0;
        [self.shadowBtn addTarget:self action:@selector(hidden) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:self.shadowBtn];
        
        UIView *baseView = [[UIView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT - ScreenX375(563), SCREEN_WIDTH, ScreenX375(563))];
        baseView.backgroundColor = [UIColor whiteColor];
        [self addSubview:baseView];
        
        UILabel *label =[[UILabel alloc] initWithFrame:CGRectMake((SCREEN_WIDTH - ScreenX375(100))/2, ScreenX375(15), ScreenX375(100), ScreenX375(18))];
        label.text = @"产品参数";
        label.font = Kfont(18);
        label.textColor = REXADECIMALCOLOR(@"#333333");
        label.textAlignment = NSTextAlignmentCenter;
        [baseView addSubview:label];
        
        UILabel *line = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(0), ScreenX375(48), SCREEN_WIDTH, ScreenX375(0.5))];
        line.backgroundColor = REXADECIMALCOLOR(@"#dcdcdc");
        [baseView addSubview:line];
        
        self.tableView = [[BaseTableView alloc] initWithFrame:CGRectMake(0,ScreenX375(50), SCREEN_WIDTH, ScreenX375(489)-ScreenX375(50))];
        self.tableView.delegate = self;
        self.tableView.dataSource = self;
        self.tableView.backgroundColor = [UIColor whiteColor];
        [baseView addSubview:self.tableView];
        
        UIButton *sureBtn = [[UIButton alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(489), SCREEN_WIDTH - ScreenX375(26), ScreenX375(44))];
        sureBtn.backgroundColor = ThemeColor;
        sureBtn.layer.cornerRadius = ScreenX375(22);
        sureBtn.clipsToBounds = YES;
        [sureBtn setTitle:@"确 定" forState:UIControlStateNormal];
        [sureBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        sureBtn.titleLabel.font = Kfont(16);
        [sureBtn addTarget:self action:@selector(hidden) forControlEvents:UIControlEventTouchUpInside];
        [baseView addSubview:sureBtn];
    }
    return self;
}

- (void)hidden {
    if (_hiddenClick) {
        _hiddenClick();
    }
}

- (void)done {
    if (_doneClick) {
        _doneClick();
    }
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 9;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSArray *titleText = [NSArray arrayWithObjects:@"印刷方式 :",@"箱型结构 :",@"材        质 :",@"表面处理 :",@"成箱方式 :",@"打包方式 :",@"内        径 :",@"外        径 :",@"数         量 :", nil];
    NSMutableArray *data = [NSMutableArray array];
    data = _dataArray;
    ProductDetialCell *cell = [ProductDetialCell cellWithTableView:tableView andIndexPath:indexPath];
    [cell initTitle:[titleText objectAtIndex:indexPath.row]];
    [cell initValue:[data objectAtIndex:indexPath.row]];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

@end
